package com.hz.framework.util;

import java.io.UnsupportedEncodingException;

/**
 * 字符集转码
 * */
public final class StringCode {
	
	public static final String doStringCode(String strArg) throws UnsupportedEncodingException{
		
		CommonUtils.deBug("原:"+strArg);
		CommonUtils.deBug("iso-8859-1:"+new String(strArg.getBytes("iso-8859-1")));
		CommonUtils.deBug("iso-8859-1+utf-8:"+new String(strArg.getBytes("iso-8859-1"),"utf-8"));
		CommonUtils.deBug("iso-8859-1+gb2312:"+new String(strArg.getBytes("iso-8859-1"),"gb2312"));
		CommonUtils.deBug("iso-8859-1+gbk:"+new String(strArg.getBytes("iso-8859-1"),"gbk"));
		CommonUtils.deBug("utf-8:"+new String(strArg.getBytes("utf-8")));
		CommonUtils.deBug("utf-8+iso-8859-1:"+new String(strArg.getBytes("utf-8"),"iso-8859-1"));
		CommonUtils.deBug("utf-8+gb2312:"+new String(strArg.getBytes("utf-8"),"gb2312"));
		CommonUtils.deBug("utf-8+gbk:"+new String(strArg.getBytes("utf-8"),"gbk"));
		CommonUtils.deBug("gb2312:"+new String(strArg.getBytes("gb2312")));
		CommonUtils.deBug("gb2312+utf-8:"+new String(strArg.getBytes("gb2312"),"utf-8"));
		CommonUtils.deBug("gb2312+iso-8859-1:"+new String(strArg.getBytes("gb2312"),"iso-8859-1"));
		CommonUtils.deBug("gb2312+gbk:"+new String(strArg.getBytes("gb2312"),"gbk"));
		if(strArg != null){
			strArg = new String(strArg.getBytes("ISO-8859-1"));
		}else{
			strArg = "";
		}		
		return strArg;
	}
	
	public static void main(String[] args) {
		try {
			StringCode.doStringCode("ÆÕÍ¨¶ÌÐÅ");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		
	}
}
